﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO;

namespace MarioArena.Launcher
{
    public partial class PopupForm : Form
    {
        private Bitmap backgroundGif;
        private string loadMessage;

        public PopupForm()
        {
            InitializeComponent();
            SetDoubleBuffered(this); //Double buffering on this form.

            System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
            Stream stream = myAssembly.GetManifestResourceStream("MarioArena.bulletbillduck.gif");
            backgroundGif = new Bitmap(stream);
            this.pbBackgroundImage.Image = backgroundGif;
        }

        /// <summary>
        /// Sets this control as double buffered.
        /// </summary>
        /// <param name="control"></param>
        public static void SetDoubleBuffered(Control control)
        {
            // set instance non-public property with name "DoubleBuffered" to true
            typeof(Control).InvokeMember("DoubleBuffered",
                BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                null, control, new object[] { true });
        }

        public void SetLoadMessage(string loadMessage)
        {
            this.loadMessage = loadMessage;
            this.labelLoadMessage.Text = loadMessage;
        }
    }
}
